package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.ysd.entity.XiangXiXinWen;
import com.ysd.util.DBManager;

public class XiangXiXinWenIdDaoImpl {
	/**
	 * 通过xiangXiXinWenId获取内容详细新闻表的数据
	 * @param id
	 * @return
	 */
	public ArrayList<XiangXiXinWen> getXiangXiXinWen(int id) {
		Connection conn = DBManager.getConnection();
		ArrayList<XiangXiXinWen> list = new ArrayList<XiangXiXinWen>();
		Statement st = null;
		ResultSet rs = null;
		try {
			st = conn.createStatement();
			String sql = "SELECT * FROM xiangxixinwen where xiangXiXinWenId= "+id;
			
			rs = st.executeQuery(sql);
			while (rs.next()) {
				XiangXiXinWen xxxw = new XiangXiXinWen(rs.getInt("xiangXiXinWenId"), rs.getString("xinWenName"),
						rs.getString("xinWenNeiRong"), rs.getInt("xinWenId"));
				list.add(xxxw);
			}
			return list;

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
